*******************************************************************************
* Purpose: Analyses with labor market outcomes 
*******************************************************************************
do "D:\Data\workdata\708296\Project - Mother groups and mental health\Do\global.do" 

use "$work\final_data1", clear

*Regressions
eststo clear
forvalue i = 1/104 {
eststo: areg barsel`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\barsel`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg sick`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\sick`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg work`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\work`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg ui`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\ui`i'", replace)
}
eststo clear
forvalue i = 1/24 {
eststo: areg empl`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\empl`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg barself`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\barself`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg sickf`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\sickf`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg workf`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\workf`i'", replace)
}
eststo clear
forvalue i = 1/104 {
eststo: areg uif`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\uif`i'", replace)
}
eststo clear
forvalue i = 1/24 {
eststo: areg emplf`i' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
parmest, format(estimate min95 max95 %8.3f p %8.1e) saving("$work\emplf`i'", replace)
}


*******************************************************************************
* Figure 4: Effects of exposure to a depressed peer on Parental leave, Self-sufficiency, 
* sick leave and unemployment benefits of mothers, weekly status measures
*******************************************************************************

use "$work\ui1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\ui`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in weeks") ytitle("Difference") ylab(-0.03(0.01)0.03, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\ui1.png", replace


use "$work\barsel1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\barsel`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in weeks") ytitle("Difference") ylab(-0.03(0.01)0.03, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\barsel1.png", replace

use "$work\sick1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\sick`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in weeks") ytitle("Difference") ylab(-0.02(0.01)0.02, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\sick1.png", replace

use "$work\work1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\work`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in weeks") ytitle("Difference") ylab(-0.04(0.01)0.04, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\work1.png", replace



//Fathers - not reported in paper as figures
use "$work\uif1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\uif`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in weeks") ytitle("Difference") ylab(-0.03(0.01)0.03, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\uif1.png", replace

use "$work\barself1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\barself`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in months") ytitle("Difference") ylab(-0.03(0.01)0.03, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\barself1.png", replace

use "$work\sickf1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\sickf`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in months") ytitle("Difference") ylab(-0.02(0.01)0.02, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\sickf1.png", replace

use "$work\workf1",clear
gen m = 1
forvalue v = 2/104 {
append using "$work\workf`v'"
replace m = `v' if m == .
}
keep if parm == "peer_treat"

replace t = round(t,0.001)
gen est2 = estimate
replace est2 = . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100 
tostring est2, gen(est3)
replace stderr = round(stderr,0.001)
replace stderr =  . if m != 10 & m != 20 & m != 30 & m != 40 & m != 50 & m != 60 & m != 70 & m != 80 & m != 90 & m != 100
twoway (scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /*mlabel(est3) mlabp(12) mlabs(tiny) mlabg(15pt) mlabc(black)*/) /// 
(scatter estimate m, msize(small) msymbol(Oh) mcolor(red) alwidth(none) lcolor(black) lwidth(thick) /* mlabel(stderr) mlabp(12) mlabs(tiny) mlabg(6pt) mlabc(black)*/) ///
(line estimate m, fcolor(black%10) alwidth(none) lcolor(red) lwidth(thick)) ///
(line max95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)) ///
(line min95 m, fcolor(black%30) alwidth(none) lcolor(gs10) lwidth(medium) lpattern(dash)), $gswl legend(off) xtitle("Age in months") ytitle("Difference") ylab(-0.04(0.01)0.04, tlcolor(gs10) labgap(6-pt) format(%4.2f)) yline(0, lcolor(gs10) lwidth(medthick))
graph export "$out\workf1.png", replace